package com.zkingsoft.actions.admin;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.actions.common.BaseController;
import com.zkingsoft.model.AppInterface;
import com.zkingsoft.model.InterfaceCate;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.plugin.util.WebUtil;
import com.zkingsoft.pojo.AjaxResult;
import com.zkingsoft.services.AppInterfaceService;
import com.zkingsoft.services.InterfaceCateService;
import com.zkingsoft.services.InterfaceParamService;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-09-09 15:09
 */
@Controller
@RequestMapping(value = "admin/appInterface")
public class AppInterfaceController extends BaseController{

	@Resource
	private AppInterfaceService currentService;
	@Resource
	private InterfaceParamService interfaceParamService;
	@Resource
	private InterfaceCateService interfaceCateService;
	
	/**
	 * 子菜单入口
	 */
	@RequestMapping(value = "/enter")
	public String enter(Long projId,String projName) {
		WebUtil.getRequest().setAttribute("projId", projId);
		WebUtil.getRequest().setAttribute("projName", projName);
		return "/admin/app-interface-list";
	}
	/**
	 * 列表显示
	 */
	@RequestMapping(value = "/showList")
	public @ResponseBody AjaxResult showList(AppInterface appInterface, PaginationVO pageVo) {
		appInterface.setUserId(getMe().getId());
		return showList(currentService, appInterface, pageVo);
	}
	 
   	
	/**
	 * 新增或者修改页面
	 */   	
   	@RequestMapping(value = "/addOrModify")
	public @ResponseBody AjaxResult addOrModify(AppInterface appInterface) {
		
   		appInterface.setUpdateUser(getMe().getName());
		appInterface.setUpdateTime(new Date());
   		if (appInterface.getId() != null) {
			return modify(currentService, appInterface, "接口");
		} else {
			appInterface.setUserId(getMe().getId());
			return add(currentService, appInterface, "接口");
		}
	}
	
   	/**
	 * 进入修改界面
	 */   
   	@RequestMapping(value = "/editForm")
	public String editForm(Long id,Long projId) {
		AppInterface appInterface;
		if (id != null) {
			appInterface = currentService.findById(id);
			WebUtil.getRequest().setAttribute("obj", appInterface);
		}
		if(projId != null){
			WebUtil.getRequest().setAttribute("projId", projId);
		}
		return "admin/appInterface-form";
	}
   	
   	
   	/**
	 * 删除
	 */  
 	@RequestMapping(value = "/del")
	public @ResponseBody AjaxResult del(String keys) {
		return remove(currentService, keys);
	}
 	
   	/**
	 * 接口类型
	 */  
 	@RequestMapping(value = "/queryInterface")
	public @ResponseBody AjaxResult queryInterface(InterfaceCate InterfaceCate) {
		return findByModel(interfaceCateService,InterfaceCate);
 	}
 	
}